package com.zxx.pattern.statePattern.state2;

/**
 * 空闲可以完成预订和入住两个动作
 *
 * @author zxx on 2021/1/18
 */
public class FreeTimeState implements State2 {

    private Room2 hotelManagement;

    public FreeTimeState(Room2 hotelManager) {
        this.hotelManagement = hotelManager;
    }

    @Override
    public void bookRoom() {
        System.out.println("您已经成功预订了...");

        //状态变成已经预订
        hotelManagement.setState2(hotelManagement.getBookedState());
    }

    @Override
    public void unsubscribeRoom() {
        //不需要做操作
    }

    @Override
    public void checkInRoom() {
        System.out.println("您已经成功入住了...");

        //状态变成已经入住
        hotelManagement.setState2(hotelManagement.getCheckInState());

        //Room2中是用 state2进行动作的执行，所以这里不能只是改变成入住状态，二是让state2改变为入住状态
        //hotelManagement.setCheckInState(hotelManagement.getCheckInState());
    }

    @Override
    public void checkOutRoom() {
        //不需要做操作
    }
}
